package com.jwater.core.manager.common;

/**
 * @description:
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public class DataKeys {
    // 共享存储KEY
    public static String KEY_ONLINE = "online";// 未持久化存储
    public static String KEY_RUN = "run";
    public static String KEY_RUN_HOST = "runHost";
    public static String KEY_JOB_RUN = "jobRun";
    public static String KEY_JOB_RUN_HOST = "jobRunHost";
    public static String KEY_JOB_LAST_RUN_TIME = "jobLastRunTime";

    // 名称KEY
    public static String KEY_RUN_WORKER = "runWorkerKey";
    public static String KEY_REGION_NAME = "regionName";
    public static String KEY_DEPLOY_NAME = "deployName";
    public static String KEY_GROUP_NAME = "groupName";
    public static String KEY_WORKER_NAME = "workerName";
    public static String KEY_INDEX = "index";

    /**
     * 获取工作进程不带index的key
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param workerName
     * @return
     */
    public static String getWorkerKey(String regionName, String deployName, String groupName, String workerName) {
        String key = regionName + ":" + deployName + ":" + groupName + ":" + workerName;
        return key;
    }

    /**
     * 获取工作进程的key
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param workerName
     * @param index
     * @return
     */
    public static String getRunWorkerKey(String regionName, String deployName, String groupName, String workerName,
                                         int index) {
        String key = regionName + ":" + deployName + ":" + groupName + ":" + workerName + ":" + index;
        return key;
    }

    /**
     * 获取离线任务的group的key
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @return
     */
    public static String getJobGroupKey(String regionName, String deployName, String groupName) {
        String key = regionName + ":" + deployName + ":" + groupName;
        return key;
    }

    /**
     * 获取离线任务key
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param jobName
     * @return
     */
    public static String getJobKey(String regionName, String deployName, String groupName, String jobName) {
        String key = regionName + ":" + deployName + ":" + groupName + ":" + jobName;
        return key;
    }
}
